﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using SERP.StringMappings;
using SERP.DAO;
using SERP.Controllers;
namespace SERP.Modules.Users{
	public partial class UsersInputFields : SERP.Modules.ModuleBase
	{
		protected void Page_Load(object sender, EventArgs e){
			LoadLanguage();
		}
		private UsersEntity model=new UsersEntity();
		public UsersEntity Model{
			set{
				model=value;
			}
			get{
				return model;
			}
		}
		//Load All lable text
		private void LoadLanguage(){
			labelUserName.Text=UsersStringMapping.UserName+":";
			labelPassword.Text=UsersStringMapping.Password+":";
			labelDisplayName.Text=UsersStringMapping.DisplayName+":";
			labelBirthDay.Text=UsersStringMapping.BirthDay+":";
			labelEmail.Text=UsersStringMapping.Email+":";
			labelGender.Text=UsersStringMapping.Gender+":";
			validRQGender.ErrorMessage=SERP.Constants.APP_REQUIRE_WARNING;	
			validExpressionGender.ErrorMessage=SERP.Constants.APP_REQUIRE_INTERGER_WARNING;
			labelAddress.Text=UsersStringMapping.Address+":";
			labelPhone.Text=UsersStringMapping.Phone+":";
			labelIsActived.Text=UsersStringMapping.IsActived+":";
			labelUserType.Text=UsersStringMapping.UserType+":";
			validRQUserType.ErrorMessage=SERP.Constants.APP_REQUIRE_WARNING;	
			validExpressionUserType.ErrorMessage=SERP.Constants.APP_REQUIRE_INTERGER_WARNING;
		}   
		public void UpdateToModel(){
			model.UserName=Convert.ToString(txtUserName.Text);
			model.Password=Convert.ToString(txtPassword.Text);
			model.DisplayName=Convert.ToString(txtDisplayName.Text);
			model.BirthDay=txtBirthDay.SelectedDate.Value;
			model.Email=Convert.ToString(txtEmail.Text);
			model.Gender=Convert.ToByte(txtGender.Text);
			model.Address=Convert.ToString(txtAddress.Text);
			model.Phone=Convert.ToString(txtPhone.Text);
			model.IsActived=txtIsActived.Checked;
			model.UserType=Convert.ToByte(txtUserType.Text);
		}
		public void UpdateToScreen(){
			txtUserName.Text=model.UserName;
			txtPassword.Text=model.Password;
			txtDisplayName.Text=model.DisplayName;
			txtBirthDay.SelectedDate=model.BirthDay;
			txtEmail.Text=model.Email;
			txtGender.Text=Convert.ToString(model.Gender);
			txtAddress.Text=model.Address;
			txtPhone.Text=model.Phone;
			txtIsActived.Checked=model.IsActived;
			txtUserType.Text=Convert.ToString(model.UserType);
		}
		public void ClearScreen(){
			txtUserName.Text="";
			txtPassword.Text="";
			txtDisplayName.Text="";
			txtEmail.Text="";
			txtGender.Text="0";
			txtAddress.Text="";
			txtPhone.Text="";
			txtUserType.Text="0";
		}
		public bool ValidateScreen(){
			bool result=true;
			return result;
		}	
	}
}
